<?php
define('LEGAL_OPER', true);
require('../includes/admin-init.php');

$pmenu = null;
$db = new DB();
$base = new BaseDao($db->getDb(),'admin_action','action_id');
$menu = $base->getAll('action_type=? and is_active=?', array(1,1),array('sort_order asc'));
if($menu != null && count($menu)>0){
	foreach ($menu as $element){
		if($element['parent_id'] == null){
			$pmenu[] = $element;
		}
	}
	if(count($pmenu)>0){
		foreach ($pmenu as $key=>$parent){
			$childs = array();
			foreach ($menu as $child){
				if($child['parent_id'] != null && $child['parent_id'] == $parent['action_id']){
					$childs[] = $child;
				}
			}
			$parent['childs'] = $childs;
			$pmenu[$key] = $parent;
		}
	}
}
$smarty->assign("menus",$pmenu);
$smarty->display("common/menu.htm");